package com.ysdcrm.crm.mapper;

import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ysdcrm.crm.model.Users;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface IUsersMapper extends BaseMapper<Users>{
    @Select("select * from users where name = #{name} and pwd = #{pwd} and status != 2")
    Users login(Users u);

    @Update("update users set pwd = #{pwd} where uid = #{uid}")
    int newPwd(Users u);

    @Select("select count(*) from users where name = #{name}")
    int getNameCount(Users u);

    @Update("update users set status = !status  where uid = #{uid}")
    int updateStatus(int uid);

    @Update("update users set status = 2  where uid = #{uid}")
    int del(int uid);

    @Update("UPDATE users SET  nickname = #{nickname}, face = #{face} WHERE uid = #{uid}")
    int edit(Users u);

    @Select("select u.name uname from users u join user_role_relation relation on u.uid = relation.uid join roles r on r.rid = relation.rid join clocks c on u.uid = c.uid where TO_DAYS(c.clock_time) = TO_DAYS(now()) and r.name = '咨询师' group by uname")
    List<String> findTodayClockIn();//查询当天签到的咨询师列表

    @Update("update users set weight = #{weight} where uid = #{uid}")
    int editWeight(Users u);
}
